# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-flex
pkgver=6.14.1
pkgrel=9
pkgdesc="Swagger schema validator"
url="https://github.com/pipermerriam/flex"
license=('BSD')
arch=('any')
depends=('python-six' 'python-yaml' 'python-validate-email' 'python-rfc3987' 'python-requests'
         'python-strict-rfc3339' 'python-click' 'python-jsonpointer')
makedepends=('python-setuptools')
checkdepends=('python-pytest-runner' 'python-factory-boy' 'python-responses' 'python-pytest-httpbin')
source=("$pkgname-$pkgver.tar.gz::https://github.com/pipermerriam/flex/archive/v$pkgver.tar.gz"
        $pkgname-werkzeug-2.1.patch::https://github.com/pipermerriam/flex/pull/236.patch)
sha512sums=('7164f70db2095041f878e2be95467aefc7c5b0b38b9792bd74127dc0769f24e99dd6d5df48a076bfb819462aa8216fd16313e5ebfa0e881ea3094d38ad409c40'
            '8f6dfeddeaa7b30df1e90af0be31382c283f67cc79c1ffb8c5fd22e87b679ce30df4ac82725d70bf2f58104316b169451e7862ccaec6f8f5c8d0f1e1c06cf7b1')

prepare() {
  patch -d flex-$pkgver -p1 < $pkgname-werkzeug-2.1.patch
  sed -i 's/<2/<3/' flex-$pkgver/setup.py
}

build() {
  cd flex-$pkgver
  python setup.py build
}

check() {
  cd flex-$pkgver
  # https://github.com/pipermerriam/flex/issues/234
  pytest --deselect 'tests/validation/request/test_request_parameter_validation.py::test_request_parameter_array_extraction[tsv-1\t2\t3]'
}

package() {
  cd flex-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
